let app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    companyId: "",
    companyName: "",
    role: "",
    roleName: ""
  },

  getData() {
    this.setData({
      companyId: app.globalData.userInfo.companyData.companyId,
      companyName: app.globalData.userInfo.companyData.companyName,
      role: app.globalData.userInfo.role,
      roleName: app.globalData.userInfo.roleName
    });
    wx.showLoading({
      title: "获取中..."
    });
    wx.$apis.getMyUserInfo(this.data.companyId).then((res) => {
      if (res.data) {
        const { mobile, realName } = res.data;
        this.setData({
          mobile,
          realName
        });
      }
    });
  },

  // 退出登录
  logout: function () {
    wx.clearStorage({
      success: (res) => {
        app.globalData = {};
        wx.reLaunch({
          url: "/pages/login/index"
        });
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData();
  },
	// 修改手机号
  toEditPhone() {
    wx.navigateTo({
      url: "/pages/management/edit-phone/index"
    });
	},
	// 品类管理
  toCategory() {
    wx.navigateTo({
      url: "/pages/management/category-management/index"
    });
  }
});
